package com.application.fabric.test.PFDca;

import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;

import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;


import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class pfdtest2 {
    public static void main(String[] args) throws Exception{
        try {
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream("src/main/java/com/application/fabric/fabriccontrol/existevidence/capool/output.pdf"));
            document.open();
            Paragraph p1 = new Paragraph("Fabric  Voucher");
            /*居中对齐*/
            p1.setAlignment(Element.ALIGN_CENTER);
            setStyle(p1,50,30,10,10,10,0);
            document.add(p1);


            Paragraph p12 = new Paragraph("--------------------------------------------------");
            /*居中对齐*/
            p12.setAlignment(Element.ALIGN_CENTER);
            setStyle(p12,50,30,10,10,10,0);
            document.add(p12);

            Paragraph p2 = new Paragraph("certificate:"+"dfrs;gokop[ergko");
            setStyle(p2,30,30,10,10,10,100);
            document.add(p2);

            Paragraph p3 = new Paragraph("hash ID:"+"liefhoiejfo");
            setStyle(p3,30,30,10,10,10,100);
            document.add(p3);


            Paragraph p4 = new Paragraph("block address:"+"liefhoiejfo");

            setStyle(p4,30,30,10,10,10,100);
            document.add(p4);

            Paragraph p5 = new Paragraph("file name:"+"liefhoiejfo");
            setStyle(p5,30,30,10,10,10,100);
            document.add(p5);

            Paragraph p6 = new Paragraph("time:"+"liefhoiejfo");
            setStyle(p6,30,30,10,10,10,100);
            document.add(p6);


            Paragraph p7 = new Paragraph("mechanism:"+"liefhoiejfo");
            setStyle(p7,30,30,10,10,10,100);
            document.add(p7);


            Paragraph p13 = new Paragraph("--------------------------------------------------");
            /*居中对齐*/
            p13.setAlignment(Element.ALIGN_CENTER);
            setStyle(p13,50,30,10,10,10,0);
            document.add(p12);


            Paragraph p8 = new Paragraph("explain:");
            setStyle(p8,30,40,10,10,10,150);
            document.add(p8);


            Paragraph p9 = new Paragraph(" This file is encrypted by sm3");
            setStyle(p9,30,20,10,10,10,160);
            document.add(p9);



            Paragraph p11 = new Paragraph("Data cannot be tampered with through fabric storage");
            setStyle(p11,30,20,10,10,10,160);
            document.add(p11);



            document.close();
        } catch (DocumentException | FileNotFoundException e) {
            e.printStackTrace();
        }
    }


    private static Paragraph setStyle(Paragraph p,int setPaddingTop,int setSize,int setColor1,int setColor2,int setColor3,int left){
      p.setPaddingTop(setPaddingTop);
//      Font font = new Font();
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 4f);
      font.setSize(setSize);
      font.setColor(setColor1,setColor2,setColor3);
      p.setFont(font);
      p.setIndentationLeft(left);
      return p;
    }

}
